package com.fenghongzhang.day004;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main4Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);

        Switch aSwitch = findViewById(R.id.ss);
        aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    Toast.makeText(Main4Activity.this, "选中", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(Main4Activity.this, "为选中", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
